let xmlhttp;

$(()=> {
  let html = "";
  if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest;
  } else {
    xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
  }
  let laptopmsg = document.getElementById('laptopmsg');
  xmlhttp.onreadystatechange = () => {
    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
      let laptops = JSON.parse(xmlhttp.responseText);
      laptops.forEach(e=> {
        html+=`<div id="produ">
          <div class="title">${e.title}</div>
    <div class="details">${e.details}</div>
  </div>
  `;

  /*  <div class="picture" id="IMG"><img src="" alt="">${e.lid}</div>
    <div class="title">${e.title}</div>
    <div class="intr">${e.subtitle}</div>
    <div class="promise">${e.promise}</div>
    <div class="spec">${e.lname}</</div>
    <div class="price">${e.price}</div> */
       /*  html += `<tr>
                <td>${laptops[i].lid}</td>
                <td>${laptops[i].family_id}</td>
                <td>${laptops[i].title}</td>
                <td>${laptops[i].subtitle}</td>
                <td>${laptops[i].price}</td>
                <td>${laptops[i].promise}</td>
                <td>${laptops[i].spec}</td>
                <td>${laptops[i].lname}</td>
                <td>${laptops[i].os}</td>
                <td>${laptops[i].memory}</td>
                <td>${laptops[i].resolution}</td>
                <td>${laptops[i].video_card}</td>
                <td>${laptops[i].cpu}</td>
                <td>${laptops[i].video_memory}</td>
                <td>${laptops[i].category}</td>
                <td>${laptops[i].disk}</td>
                <td>${laptops[i].details}</td>
                <td>${laptops[i].shelf_time}</td>
                <td>${laptops[i].sold_count}</td>
                <td>${laptops[i].is_onsale}</td>
                <td><a href="javascript:deleL(${laptops[i].lid})">删除</a></td>
                </tr>`; */
      });
      // document.getElementById('box').innerHTML = html;
      $("#box").html(html);
    }
  }
  xmlhttp.open('GET', "http://127.0.0.1:8080/v1/laptops/list", true);
  xmlhttp.send();
});